package fr.umlv.m2.jee.pmlv.service.planning.impl;

import fr.umlv.m2.jee.pmlv.persistence.planning.Classroom;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fr.umlv.m2.jee.pmlv.persistence.planning.EventLesson;
import fr.umlv.m2.jee.pmlv.persistence.planning.Projector;
import fr.umlv.m2.jee.pmlv.persistence.planning.dao.IEventLessonDAO;
import fr.umlv.m2.jee.pmlv.service.planning.DisplayAbstractEvent;
import fr.umlv.m2.jee.pmlv.service.planning.IDisplayEventLessonService;
import java.util.Date;

@Service("defautDisplayEventLessonService")
public class DefautDisplayEventLessonService implements IDisplayEventLessonService{
	
	@Autowired
	@Qualifier("hibernateEventLessonDAO")
	private IEventLessonDAO dao;
	
	@Override
    @Transactional(readOnly=true)
	public List<DisplayAbstractEvent> getLessonByWeekAndByProfessorUid(GregorianCalendar start, String uid) {
            ArrayList< DisplayAbstractEvent > result = new ArrayList< DisplayAbstractEvent >(16);
            /* for(EventLesson eventLesson : dao.findByWeek(start) ) {
            result.add(new DisplayEventExam(eventLesson));
            }*/
            EventLesson e = new EventLesson();
            e.setBegin(new Date(111, 03, 05, 9, 00));
            e.setEnd(new Date(111, 03, 05, 11, 00));
            Classroom c = new Classroom(); c.setNumber("2B105"); e.setClassroom(c);
            result.add(new DisplayAbstractEvent(e));
            
            EventLesson l = new EventLesson();
            l.setBegin(new Date(111, 03, 06, 15, 00));
            l.setEnd(new Date(111, 03, 06, 17, 00));
            Classroom r = new Classroom(); r.setNumber("2B105"); l.setClassroom(r);
            Projector p = new Projector(); p.setName("001"); l.setProjector(p);
            result.add(new DisplayAbstractEvent(l));

            return result;
	}

	@Override
    @Transactional
	public void addEvent(EventLesson eventLesson) {
		dao.merge(eventLesson);
	}



}
